asp.net MVC

The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net

The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net, someone asked me to explain?

I got this following error "Could not create SSL/TLS secure channel" in your ASP.NET MVC WebClient application.

The Request was aborted

CODE:

    WebClient webClient = new WebClient();
    string content = webClient.DownloadString(url);
    HtmlDocument doc = new HtmlDocument();
    doc.LoadHtml(content);

SOLUTION:

Client servers might supported by SSL/TLS protocol versions. So you may specify the SSL/TLS protocol version in your code.

    WebClient webClient = new WebClient();
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    string content = webClient.DownloadString(url);
    HtmlDocument doc = new HtmlDocument();
    doc.LoadHtml(content);

VIDEO GUIDE:

Post your comments / questions